package com.hutiao.snowhb.entities;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class Page implements Serializable {

	private static final long serialVersionUID = 153289675517956783L;
	
	private int pageSize;     //每页的数量
	
    private int totalPage;   //总页数
    
    private int rowCount;	 //总数量
    
    private int currentPage; //当前页数
    
    private int prePage; //上一页
    
    private int nextPage;	 //下一页
    
    private boolean hasNextPage;	 //是否有下一页
    
    private boolean hasPreviousPage;	 //是否有下一页
    
    private List list;	 //返回的数据
    
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	public int getTotalPage() {
		return totalPage;
	}
	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}
	public int getRowCount() {
		return rowCount;
	}
	public void setRowCount(int rowCount) {
		this.rowCount = rowCount;
	}
	public int getCurrentPage() {
		return currentPage;
	}
	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}
	public int getPrePage() {
		return prePage;
	}
	public void setPrePage(int prePage) {
		this.prePage = prePage;
	}
	public int getNextPage() {
		return nextPage;
	}
	public void setNextPage(int nextPage) {
		this.nextPage = nextPage;
	}
	public boolean isHasNextPage() {
		return hasNextPage;
	}
	public void setHasNextPage(boolean hasNextPage) {
		this.hasNextPage = hasNextPage;
	}
	public boolean isHasPreviousPage() {
		return hasPreviousPage;
	}
	public void setHasPreviousPage(boolean hasPreviousPage) {
		this.hasPreviousPage = hasPreviousPage;
	}
	public List getList() {
		return list;
	}
	public void setList(List list) {
		this.list = list;
	}
	
	public Page(int currentPage) {
		super();
		this.currentPage = 1;
		this.list = new ArrayList();
	}
	
	public void build(int pageSize, int rowCount, List datas) {
		this.pageSize = pageSize;
		this.rowCount = rowCount;
		
		this.totalPage = (rowCount%pageSize)==0 ? (rowCount/pageSize) : (rowCount/pageSize + 1);
		this.nextPage = this.currentPage + 1;
		this.prePage = this.currentPage - 1;
		this.hasNextPage = this.currentPage<this.totalPage ? true : false;
		this.hasPreviousPage = this.currentPage>1 ? true : false;
		
		this.list = datas;
	}

}
